/**
 * ApplicationServletContextListener.java	  V1.0   2014-4-10 上午11:08:46
 *
 * Copyright GTA Information System Co. ,Ltd. All rights reserved.
 *
 * Modification history(By    Time    Reason):
 * 
 * Description:
 */

package com.lhyl.front.listener; 

    
import java.util.Map;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

 
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.lhyl.front.common.AppPropertiesUtil;
import com.lhyl.front.common.FrontPropertyPlaceholderConfigurer;
import com.lhyl.front.constant.FrontConstant;


 
/***
 * 
 * @author hongwu.huang
 *
 */
public class AppServletContextListener implements ServletContextListener {
 
	@Override
	public void contextDestroyed(ServletContextEvent event) {
		AppPropertiesUtil.clearProperties();
		 
	}

	@Override
	public void contextInitialized(ServletContextEvent event) {
		//系统启动初始化一些系统变量
		WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(event.getServletContext());
		FrontPropertyPlaceholderConfigurer propertyBean = (FrontPropertyPlaceholderConfigurer) 
				wac.getBean(FrontConstant.PROPERTY_CONFIGURER);
		Map<String, String> maps = propertyBean.getCtxPropertiesMap();
		AppPropertiesUtil.putProperties(maps); 
	}

}
